//
//  TraderMoneyDetailViewController.m
//  WGFGlobalHouses
//
//  Created by zhouhui on 15/4/19.
//  Copyright (c) 2015年 waiguofang. All rights reserved.
//   分销商－－佣金明细

#import "TraderMoneyDetailViewController.h"
#import "StroeMoneyViewController.h"
#import "TraderMoneyDetailCell.h"
#import "MoneyDetail.h"


@interface TraderMoneyDetailViewController ()<UITableViewDelegate,UITableViewDataSource,traderMoneyDetailCellDelegate>

@property (weak, nonatomic) IBOutlet UIButton *firstBtn;
- (IBAction)clickBtn:(UIButton *)sender;
@property (weak, nonatomic) IBOutlet UILabel *lab;
//保存选中的按钮
@property (strong, nonatomic) UIButton *selectdBtn;

@end

@implementation TraderMoneyDetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
   
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    self.tableView.rowHeight = 174;
    self.tableView.allowsSelection = NO;
    [self addSearchRightItem];
    [self addMoneyDetailView];
}

-(void)addMoneyDetailView
{
    MoneyDetail *moneyView = [MoneyDetail initWithXib];
    moneyView.frame = CGRectMake(0, 136, UIScreenWidth, 88);
    [self.view addSubview:moneyView];
}
-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:YES];
    self.showSearchView = NO;
    [self clickBtn:self.firstBtn];
   
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
#pragma  mark 响应导航栏右侧的查询按钮
-(void)clickSearchItem
{
    
    if (!self.showSearchView)
    {
        [self showSearhRightItemView];
    }
    else
    {
        [self hiddenSearchView];
    }
    
   
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 10;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    TraderMoneyDetailCell *cell = [TraderMoneyDetailCell cellWithTableView:tableView];
    cell.delegate = self;
    return cell;
}

-(void)tableView:(UITableView *)tableView
didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView  deselectRowAtIndexPath:indexPath animated:YES];
}

#pragma mark 点击按钮“全部”，“本期结算周期” “往期结算周期”
- (IBAction)clickBtn:(UIButton *)sender {
    
    self.selectdBtn.selected = NO;
    sender.selected = YES;
    self.selectdBtn = sender;
}

#pragma mark traderMoneyDetailCell的代理，响应点击了“经纪人名称”或者“门店名”
-(void)traderMoneyDetailCellClickBtnWithBtnTag:(NSInteger)btnTag
{
    StroeMoneyViewController *vc = [[StroeMoneyViewController alloc]initWithNibName:@"StroeMoneyViewController" bundle:nil];
    
    if (btnTag == 0)
    {
        vc.viewFlag = isPersonalMoneyView;
    }
    else
    {
        vc.viewFlag = isMiddleManMoneyOfStoreView;
    }
    
    [self.navigationController pushViewController:vc animated:YES];
}
@end
